////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
//	 Title :  CBitmap.h
//
//	 Description : This class handles several different methods of text display; Basic bitmap font text,
//				kerned bitmap font text, and timed bitmap font text.
//
//   Basic Text :  If you want to print out just a basic bitmap font, you need to set up the;
//				   m_nNumberOfColumns, the m_nWidth and m_nHeight of each character, the starting
//				   m_cStartChar offset, and the m_nImageID(which holds the image of the bitmap sheet).
//				   to print it out you call DrawTextA()
//
//
//	Authors:   Devan Oatney
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////




#pragma once
#include "../Renderer/Header Files/CRendererIncludes.h"
#include <string>
using namespace std;
class CBitmap
{
private:
	////////////////////////////////////////////////////////////////////////////////////////////////////
	//variables used for basic text display
	int m_nNumberOfColumns;
	int m_nNumberOfRows;
  	int m_nWidth;
  	int m_nHeight;
	char m_cStartChar;//some sort of offset thingy
			 //first character on the bitmap
			 // currentChar - startChar(32)
	int m_nImageID;
	////////////////////////////////////////////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////////////////////////////////////////////
	//variables used for kerning
	RECT m_nCharWidth[94];
	////////////////////////////////////////////////////////////////////////////////////////////////////
public:
	//mutators
	void SetNumberOfColumns(int _numOfCols){m_nNumberOfColumns = _numOfCols;}
	void SetWidth(int _Width){m_nWidth = _Width;}
	void SetHeight(int _Height){m_nHeight = _Height;}
	void SetStartChar(char _Start){m_cStartChar = _Start;}
	void SetImageID(int _image) {m_nImageID = _image;}
	void SetNumberOfRows(int _numOfRows){m_nNumberOfRows = _numOfRows;}
	//accessors
	int GetNumberOfColumns(){return m_nNumberOfColumns;}
	int GetWidth(){return m_nWidth;}
	int GetHeight(){return m_nHeight;}
	char GetStartChar(){return m_cStartChar;}
	int GetImageID(){return m_nImageID;}
	
	
	//basic draw
	void DrawText(string _stuffToPrint, D3DXVECTOR3 _nPos, D3DXVECTOR3 _fScale);
	void PrintTextKerned(string _text, D3DXVECTOR3 _nPos, D3DXVECTOR3 _fScale);
	//this is the white text, this call fills in the character width offsets for kerning, using the measurements for that specific bitmap
	void LoadBasicText();
	//algorithm to find the rectangle for the current tile you want to use
	RECT CellAlgorithm(int id)
	{
		RECT rCell;
		rCell.left = (id %  m_nNumberOfColumns) * m_nWidth;
		rCell.top = (id / m_nNumberOfColumns) * m_nHeight;
		rCell.right = rCell.left + m_nWidth;
		rCell.bottom = rCell.top + m_nHeight;
		return rCell;
	}
};
